app.controller('BusTaskModalCtrl', function ($scope,$filter, $modalInstance, $modal, toaster, param, ajax) {

    $scope.param = param;
    if ($scope.param.data == null) {
        $scope.param.data = {};
    }

	//任务状态
	$scope.loadStatusList = function () {
		$scope.statusList =
			[
				{ id: 1, name: "已创建" },
				{ id: 2, name: "已分配" },
				{ id: 3, name: "进行中" },
				{ id: 4, name: "已完成" },
				{ id: 5, name: "已取消" },
			];
		if ($scope.param.data.status != 0) {
			$scope.statusList.selected = $scope.statusList[$scope.param.data.status - 1];
		}
	};

	$scope.loadStatusList();


    $scope.ok = function () {
    	  if($scope.statusList.selected != undefined){
    		  $scope.param.data.status=$scope.statusList.selected.id;
    	  }else{
    		  $modalInstance.dismiss('cancel');
    	  }
          var modalInstance = $modal.open({
              templateUrl: 'template/bus/task/updateModal.html?v=54719dcfa9',
              controller: 'BsTaskMeassgeCtrl',
              size: 'sm',
              resolve: {
                  param: function () {
                      return {
                          "data": $scope.param
                      };
                  }
              }
          });
          modalInstance.result.then(function (param) {
        	  $modalInstance.close($scope.param);
          });
    };

	$scope.explain = function () {
		$modal.open({
			templateUrl: 'template/bus/task/explain.html?v=40b796109d',
			controller: 'BsTaskExplainCtrl',
			size: 'lg',
			resolve: {
				param: function () { return {}; }
			}
		});
	};
    
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };
});


app.controller('BsTaskExplainCtrl', function ($scope, $modalInstance) {

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
	};
});

app.controller('BsTaskMeassgeCtrl', function ($scope, $modalInstance,param) {
    $scope.param = param;
    $scope.ok = function () { $modalInstance.close(param); };
    $scope.cancel = function () { $modalInstance.dismiss('cancel'); };
});